package com.neusoft.blog.controller;

import com.github.pagehelper.PageInfo;
import com.neusoft.blog.bean.Category;
import com.neusoft.blog.bean.RespBean;
import com.neusoft.blog.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cat")
public class CategoryController {
    @Autowired
    CategoryService categoryService;
    @GetMapping("/getCategory")
    public PageInfo getCategory( @RequestParam(value = "pageNum" ,defaultValue = "0")Integer pageNum,@RequestParam(value = "pageSize" ,defaultValue = "0") Integer pageSize){//第几页和没·页几条
        return categoryService.getCategory(pageNum,pageSize);
    }
    @PostMapping("/addCategory")
    public RespBean addCategory (@RequestBody Category category){
        return categoryService.addCategory(category);

    }
    @DeleteMapping("/delCategory/{id}")
    public RespBean delCategory (@PathVariable("id") Integer id){
        return categoryService.delCategory(id);
    }
    @PutMapping("/updateCategory")
    public RespBean updateCategory (@RequestBody Category category){
        return categoryService. updateCategory(category);
    }
    @DeleteMapping("/multiDel")
    public  RespBean multiDel(Integer[] ids){
        return categoryService.multiDel(ids);

    }
}
